<template>
  <div class="">
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="item in banner" :key="item.id">
        <img height="200" :src="item.picUrl" alt="" />
      </van-swipe-item>
    </van-swipe>

    <h1>人气推荐</h1>
    <div class="con">
      <my-list v-for="item in list" :key="item.id" :item="item" />
    </div>
  </div>
</template>

<script>
import { ref, reactive, toRefs } from "vue";
import { useStore } from "vuex";
import { useRouter, useRoute } from "vue-router";
import { getBanner, getList } from "../utils/yx";
import myList from "../components/myList.vue";
export default {
  setup(props, ctx) {
    const store = useStore();
    const router = useRouter();
    const route = useRoute();
    const data = reactive({
      banner: [],
      list: [],
    });
    getBanner().then((res) => {
      console.log(res);
      data.banner = res.data;
    });

    getList().then((res) => {
      console.log(res);
      data.list = res.data.slice(9, 13);
      //截取四个
    });

    return { ...toRefs(data) };
  },
  components: {
    myList,
  },
};
</script>

<style lang="scss">
.con {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  div {
    width: 48%;
    img {
      width: 100%;
      height: 200px;
    }
  }
}
</style>
